//
//  BlankView.m
//  shh
//
//  Created by DS on 2018/5/27.
//  Copyright © 2018年 徐双. All rights reserved.
//

#import "BlankView.h"

@interface BlankView()
//空页
Strong UIView * blankView;
Strong UIImageView * picImageView;
Strong UILabel * titleLabel;
Strong UILabel * subTitleLabel;


@end

@implementation BlankView

- (instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        ws(self)
        
        _blankView = [[UIView alloc] initWithFrame:CGRectMake(0,0, SCREEN_WIDTH, SCREEN_HEIGHT)];
        _blankView.backgroundColor = getColor(whiteColor);
        
        [self addSubview:self.blankView];
        
        _picImageView = [UIImageView new];
        _picImageView.image = [UIImage imageNamed:@"404"];
        
        
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = DEF_FontSize_15;
        _titleLabel.textColor = getColor(@"696969");
        _titleLabel.text = @"网络出问题啦";
        
        _subTitleLabel = [[UILabel alloc] init];
        _subTitleLabel.font = DEF_FontSize_11;
        _subTitleLabel.textColor = getColor(@"8C8C8C");
        _subTitleLabel.text = @"网络或服务器出问题了，试试刷新";
        
        _refreshBtn = [[UIButton alloc] init];
        [_refreshBtn setTitle:@"刷新一下试试" forState:UIControlStateNormal];
       // [_refreshBtn addTarget:self action:@selector(refreshBtnClick) forControlEvents:UIControlEventTouchUpInside];
        _refreshBtn.titleLabel.font = DEF_FontSize_13;
        _refreshBtn.layer.cornerRadius = 5;
        [_refreshBtn.layer setMasksToBounds:YES];
        _refreshBtn.layer.borderWidth = 1;
        _refreshBtn.layer.borderColor = getColor(@"E8E8E8").CGColor;
        
        [_refreshBtn setTitleColor:getColor(@"696969") forState:UIControlStateNormal];
        
        [_blankView sd_addSubviews:@[self.picImageView,self.titleLabel,self.subTitleLabel,self.refreshBtn]];
        
        [self.picImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(UNIT_HEIGHT(103) + height64);
            make.left.mas_equalTo(UNIT_WIDTH(89));
            make.width.mas_equalTo(UNIT_WIDTH(SCREEN_WIDTH - UNIT_WIDTH(89) * 2));
            make.height.mas_equalTo(UNIT_HEIGHT(200));
        }];
        
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(weakself.picImageView.mas_bottom).offset(UNIT_HEIGHT(30));
            make.centerX.mas_equalTo(weakself.picImageView.mas_centerX);
            make.height.mas_equalTo(UNIT_HEIGHT(30));
        }];
        
        [self.subTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(weakself.titleLabel.mas_bottom).offset(UNIT_HEIGHT(10));
            make.centerX.mas_equalTo(weakself.picImageView.mas_centerX);
        }];
        
        [self.refreshBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(weakself.subTitleLabel.mas_bottom).offset(UNIT_HEIGHT(30));
            make.centerX.mas_equalTo(weakself.subTitleLabel.mas_centerX);
            make.height.mas_equalTo(UNIT_HEIGHT(30));
            make.width.mas_equalTo(UNIT_WIDTH(120));
        }];
     
    }
    
    return self;
}



@end
